#include <bits/stdc++.h>
using namespace std;
#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;
int main()
{
int n, m, k;
scd(n);
scd(m);
scd(k);
k++;
vvi vec(n + 1, vi(m + 1));
forr(i, 1, n + 1)
{
string row;
cin >> row;
forr(j, 1, m + 1)
{
vec[i][j] = row[j - 1] - '0';
}
}
vector<vector<vi>> dp(n + 1, vector<vi>(m + 2, vi(k, -1e9)));
forr(i, 1, m + 1)
{
dp[1][i][vec[1][i] % k] = vec[1][i];
}
forr(i, 2, n + 1)
{
forr(j, 1, m + 1)
{
frange(l, k)
{
dp[i][j][l] = max(dp[i - 1][j - 1][(l - vec[i][j] + 10 * k) % k] + vec[i][j], dp[i - 1][j + 1][(l - vec[i][j] + 10 * k) % k] + vec[i][j]);
}
}
}
int ma = -1e9;
int id = 0;
forr(j, 1, m + 1)
{
if (dp[n][j][0] > ma)
{
ma = dp[n][j][0];
id = j;
}
}
if (ma >= 0)
{
printf("%d\n%d\n", ma, id);
int l = 0;
for (int i = n; i >= 2; i--)
{
if (dp[i][id][l] - vec[i][id] == dp[i - 1][id - 1][(l - vec[i][id] + 10 * k) % k])
{
printf("L");
l = (l - vec[i][id] + 10 * k) % k;
id = id - 1;
}
else
{
printf("R");
l = (l - vec[i][id] + 10 * k) % k;
id = id + 1;
}
}
}
else
printf("-1");
}
260. Single Number III | 240. Search a 2D Matrix II |
238. Product of Array Except Self | 229. Majority Element II |
222. Count Complete Tree Nodes | 215. Kth Largest Element in an Array |
198. House Robber | 153. Find Minimum in Rotated Sorted Array |
150. Evaluate Reverse Polish Notation | 144. Binary Tree Preorder Traversal |
137. Single Number II | 130. Surrounded Regions |
129. Sum Root to Leaf Numbers | 120. Triangle |
102. Binary Tree Level Order Traversal | 96. Unique Binary Search Trees |
75. Sort Colors | 74. Search a 2D Matrix |
71. Simplify Path | 62. Unique Paths |
50. Pow(x, n) | 43. Multiply Strings |
34. Find First and Last Position of Element in Sorted Array | 33. Search in Rotated Sorted Array |
17. Letter Combinations of a Phone Number | 5. Longest Palindromic Substring |
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |